package cn.chengpengper.im.common.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/*@formatter:off*/

/**
 * ____________________
 * < 神兽护体，永无bug! >
 * --------------------
 *
 * @author huchengpeng
 * @version v1.0.0
 * @date 2024/9/8 17:44
 * @description 终端类型
 */

/*@formatter:on*/

@Getter
@AllArgsConstructor
public enum IMTerminalType {
    WEB(1, "web"),
    APP(2, "app"),
    ;
    private final Integer code;
    private final String desc;

    public static IMTerminalType fromCode(Integer code) {
        for (IMTerminalType typeEnum : values()) {
            if (typeEnum.code.equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static List<Integer> codes() {
        return Arrays.stream(values()).map(IMTerminalType::getCode).collect(Collectors.toList());
    }
}
